package com.bs.blogspace.controller;

import com.bs.blogspace.anno.Log;
import com.bs.blogspace.model.Result;
import com.bs.blogspace.pojo.Comment;
import com.bs.blogspace.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Slf4j
public class CommentController {
    @Autowired
    private CommentService commentService;


    @PostMapping("/commentEssay")
    @ResponseBody
    public Result<Comment> commentEssay(@RequestBody Comment comment){
        log.info("发布评论，{}",comment);
        return commentService.addComment(comment);
    }

    @GetMapping("/deleteComment")
    @ResponseBody
    public Result deleteComment(@RequestParam("commentId") String commentId){
        log.info("删除评论，{}",commentId);
        return commentService.deleteComment(commentId);
    }
}
